package cn.edu.zafu.bigdata.YinMingyan.chapter10;

import java.time.LocalTime;

class TimerThread extends Thread {
    @Override
    public void run() {
        while (true) {
            System.out.println(LocalTime.now());
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                break;
            }
        }
    }
}


class MyThread implements Runnable{
    @Override
    public void run(){
        int count = 0;
        while(count++<100){
            System.out.println(count);
            try{
                Thread.sleep(100);
            }catch(InterruptedException e){
                throw new RuntimeException(e);
            }
        }
    }


}


public class ThreadDaemonDemo{
    public static void main(String[] args) {
        Thread t1 = new Thread(new MyThread());
        Thread t2 = new TimerThread();
        t1.start();
        t2.setDaemon(true);
        t2.start();

    }

}